
//获取到账户名，根据账户名进行查讯信息
let name =sessionStorage.getItem("name");
if(name){
    $.ajax({
        url:`http://127.0.0.1:8088/zhanghao?name=${name}`,
        success(data){
            $(`
                <li><span>${data[0].id}</span></li>
                <li><span>${data[0].name}</span></li>
                <li><span>${data[0].password}</span></li>
                <li><span>${data[0].dizhi}</span><button>更改</button></li>
                `).prependTo("#xin-con .re");


                //修改信息
                $("#xin-con .re button").click(function(){
                    
                    if(confirm("你确定要修改吗？？")){
                        let neirong = $(this).closest("li").find("span").html();
                        let http = new XMLHttpRequest();
                        http.open("get",`http://127.0.0.1:8088/zhangxiugai?xinxi=${neirong}&id=${name}`);
                        http.send();
                        http.onreadystatechange = function(){
                            if(http.readyState === 4){
                                if(http.responseText){
                                    alert("修改成功");
                                    location.href = "http://127.0.0.1/zkhl/qian/zhanghuxinxi.html"
                                }
                            }
                        }
                    }
                })
        }
    })
}else{
    location.href = "http://127.0.0.1/zkhl/qian/index.html"
}